#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>

int main()
{
    close(1);

    int fd = open("log.txt", O_CREAT | O_WRONLY | O_TRUNC, 0666);
    if(fd < 0) exit(1);

    printf("fd->%d\n", fd);
    printf("hello bit\n");
    printf("hello bit\n");
    printf("hello bit\n");
    printf("hello bit\n");
    printf("hello bit\n");

    fflush(stdout);

    const char* msg = "hello write\n";
    write(fd, msg, strlen(msg));

    close(fd);

    return 0;
}
